<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      .father {
        width: 400px;
        height: 400px;
        border: 2px solid #000;
        position: relative;
        transition: all 2s linear; /* 父元素的过渡效果 */
      }

      .son {
        width: 155px;
        height: 155px;
        background-color: orange;
        position: absolute;
        margin: auto;
        top: 0;
        bottom: 0;
        left: 0;
        right: 0;
        transition: all 2s linear; /* 子元素的过渡效果 */
      }

      .father:hover {
        background-color: yellow; /* 鼠标悬停时父元素的样式变化 */
      }

      .father:hover .son {
        background-color: green; /* 鼠标悬停在父元素上时子元素的样式变化 */
      }
    </style>
  </head>
  <body>
    <div class="father">
      <div class="son">子元素</div>
    </div>
  </body>
</html>
